//
//  ExtractSubViewsBootcamp_22.swift
//  SwiftUiExercise
//
//  Created by 徐鹏 on 2023/6/30.
//

import SwiftUI

struct ExtractSubViewsBootcamp_22: View {
    var body: some View {
        ZStack{
            Color.orange.edgesIgnoringSafeArea(.all)
            
            contentLayer
        
        }
    }
    
    var contentLayer: some View{
        HStack {
            myItem(title: "Apples", count: 1, color: .gray)
            myItem(title: "Apples", count: 1, color: .green)
            myItem(title: "Apples", count: 1, color: .red)
        }
    }
    
    
}

struct ExtractSubViewsBootcamp_22_Previews: PreviewProvider {
    static var previews: some View {
        ExtractSubViewsBootcamp_22()
    }
}


struct myItem: View{
    
    let title: String
    let count: Int
    let color: Color
    
    var body: some View{
        VStack{
            Text("\(count)")
            Text("\(title)")
        }
        .padding()
        .background(color)
        .cornerRadius(10)
    }
  
}
